--
-- @Author:      name
-- @DateTime:    2018-03-30 23:05:48
-- @Description: 消息的处理

local skynet = require "skynet"
-- local config = require "configquery"

local MessageHandler = class("MessageHandler")

---------------------------------------------------------
-- Private
---------------------------------------------------------
function MessageHandler:ctor(message_dispatch, node_message)

	self.message_dispatch = message_dispatch
	self.node_message = node_message

	self:register()
end

--注册本服务里的消息
function MessageHandler:register()
	--启动
	self.message_dispatch:registerSelf('start', handler(self,self.start))
	self.message_dispatch:registerSelf("disconnect", handler(self,self.disconnect))	
end


------------------------------------------------------------------
--cmd
------------------------------------------------------------------
function MessageHandler:start()

    self.client_handler = global.client_handler        
    self.user_manager = global.user_manager
    self.table_manager = global.table_manager

    self.client_handler:start()
    self.user_manager:start()
    self.table_manager:start()

	--skynet控制台
	-- skynet.newservice("debug_console", svr_config.debug_port)
end


--用户掉线
function MessageHandler:disconnect(user_id)
	debug_log("_________hall_disconnect__",user_id)
	self.user_manager:removeUser(user_id)
end

return MessageHandler